local joyex__qimou = fk.CreateSkill {

  name = "joyex__qimou",

  tags = { Skill.Limited, },

}



joyex__qimou:addEffect("active", {
  name = "joyex__qimou",
  anim_type = "offensive",
  card_num = 0,
  target_num = 0,
  frequency = Skill.Limited,
  interaction = function(self,player)
    return UI.Spin {
      from = 1,
      to = player.hp,
    }
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(joyex__qimou.name, Player.HistoryGame) == 0 and player.hp > 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local tolose = self.interaction.data
    room:loseHp(player, tolose, joyex__qimou.name)
    if player.dead then return end
    room:setPlayerMark(player, "@joyex__qimou-turn", tolose)
    player:drawCards(1, joyex__qimou.name)
  end,
})

joyex__qimou:addEffect("targetmod", {
  name = "#joyex__qimou_targetmod",
  residue_func = function(self, player, skill, scope)
    if skill.trueName == "slash_skill" and scope == Player.HistoryPhase then
      return player:getMark("@joyex__qimou-turn") or 0
    end
  end,
})

joyex__qimou:addEffect("distance", {
  name = "#joyex__qimou_distance",
  correct_func = function(self, from, to)
    return -from:getMark("@joyex__qimou-turn")
  end,
})

return joyex__qimou